<%-- 
    Document   : checkout
    Created on : 16-Jul-2013, 23:24:14
    Author     : MrMAD
--%>

<%@page import="mybean.Order"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Book Store</title>
        <meta name="keywords" content="Book Store" />
        <meta name="description" content="Hoa Lac Book Store" />
        <link href="MyCss/mycss.css" rel="stylesheet" type="text/css" />

        <style>
            h1 {
                font-size: 14px;
                color: #cbc750;
                padding: 0px 10px 5px 200px;
                margin: 0px 20px 10px 20px;  
            }
        </style>
    </head>
    <body>
        <div id="templatemo_container">

            <%@include file="MyContent/header.jsp" %>

            <div id="templatemo_content">

                <%@include file="MyContent/list_all_category.jsp" %>

                <%
                    String email = (String) session.getAttribute("email");
                    String books = "";

                    Cookie cookie = null;
                    Cookie[] cookies = null;

                    cookies = request.getCookies();
                    if (cookies != null) {
                        for (int i = 0; i < cookies.length; i++) {
                            cookie = cookies[i];
                            try {
                                Integer.parseInt(cookie.getName());
                                Integer.parseInt(cookie.getValue());
                                books += cookie.getName() + "=" + cookie.getValue() + "  ";
                            } catch (Exception e) {
                                continue;
                            }
                        }
                    }
                    Order newOrder = new Order(email, books, session.getAttribute("totalQuantity").toString(), session.getAttribute("totalCash").toString());
                    Boolean saveOrder = newOrder.save();
                    if (saveOrder) {
                        out.println("<br><h1>Your order has been saved!</h1><br>");
                    } else {
                        out.println("<br><h1>Sorry. Your order has been rejected.</h1><br>");
                    }
                %>                

                <div class="cleaner_with_height">&nbsp;</div>
            </div> <!-- end of content -->

            <%@include file="MyContent/footer.html" %>            
        </div> 
        <!-- end of container -->  
    </body>
</html>
